#include <pthread.h>
#include <unistd.h>

extern int ui_main(void);
extern int v4l2_main(void);
extern void ui_init(void);
extern void remote_main(void);

static pthread_t threadV4l2;
static pthread_t threadGUI;
static pthread_t threadRemoter;

void RaiseThreadV4L2(void);
void RaiseThreadGUI(void);
void RaiseThreadRemoter(void);

int main(int argc, char *argv[])
{
	ui_init();
	RaiseThreadGUI();
	RaiseThreadV4L2();
	RaiseThreadRemoter();

    pthread_join(threadV4l2, NULL);
    pthread_join(threadGUI, NULL);
    pthread_join(threadRemoter, NULL);

	return 0;
}

void RaiseThreadV4L2(void)
{
	int ret = pthread_create(&threadV4l2, NULL, (void*)v4l2_main, NULL);
	if (ret != 0) {
		return -1;
	}
}

void RaiseThreadGUI(void)
{
	int ret = pthread_create(&threadGUI, NULL, (void*)ui_main, NULL);
	if (ret != 0) {
		return -1;
	}
}

void RaiseThreadRemoter(void)
{
	int ret = pthread_create(&threadRemoter, NULL, (void*)remote_main, NULL);
	if (ret != 0) {
		return -1;
	}
}